home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
User's Choice Windows CD
/
User's Choice Windows CD (CMS Software)(1993).iso
/
win_q_t
/
trem.zip
/
COMEVENT.C
< prev
next >
Wrap
Text File
|
1991-05-11
|
4KB
|
154 lines
/************************************************************************
*
* Copyright (c) 1991 Microsoft Corporation. All Rights Reserved.
*
*-----------------------------------------------------------------------
*
* Project: Windows Terminal Example
*
* Module: comevent.c
*
* Author: Bryan A. Woodruff (baw)
*
*
* Remarks: Comm Event Timer Stuff
*
* Revisions:
* 01.00.000 5/ 9/91 baw Wrote it
*
************************************************************************/
#include "terminal.h"
/************************************************************************
* BOOL SetEvent( HWND hWnd, int nCid, WORD wEventMask )
*
* Description:
* Creates an event in the event structure. If the same event
* has already been flagged, this routine returns TRUE.
*
* Comments:
* 5/ 9/91 baw Wrote it
*
************************************************************************/
BOOL SetEvent( HWND hWnd, int nCid, WORD wEventMask, WORD wMsg )
{
int i ;
if (!nIdTimer)
{
lpTimerProc = MakeProcInstance( TimerHandler, hAppInst ) ;
nIdTimer = SetTimer( NULL, TIMER_EVENT, TIMER_INTERVAL,
lpTimerProc ) ;
if (!nIdTimer)
return ( FALSE ) ;
}
// if same event already exists, just return TRUE
for (i = 0; i < MAXEVENTS; i++)
if (aEvents[i].hWnd == hWnd &&
aEvents[i].nCid == nCid &&
aEvents[i].wEventMask == wEventMask)
return ( TRUE ) ;
// find empty spot in events list
for (i = 0; i < MAXEVENTS; i++)
{
if (aEvents[i].hWnd == NULL)
{
aEvents[i].nCid = nCid ;
aEvents[i].wEventMask = wEventMask ;
aEvents[i].lpEventPtr = SetCommEventMask( nCid, wEventMask ) ;
aEvents[i].wMsg = wMsg ;
aEvents[i].fPostFlag = FALSE ;
aEvents[i].hWnd = hWnd ;
return ( TRUE ) ;
}
}
return ( FALSE ) ;
} /* end of SetEvent() */
/************************************************************************
* VOID KillEvent( HWND hWnd, int nCid, WORD wEventMask )
*
* Description:
* Removes event from event list.
*
* Comments:
* 5/ 8/91 baw Wrote it.
*
************************************************************************/
VOID KillEvent( HWND hWnd, int nCid, WORD wEventMask )
{
int i ;
for (i = 0; i < MAXEVENTS; i++)
{
if (aEvents[i].hWnd == hWnd &&
aEvents[i].nCid == nCid &&
aEvents[i].wEventMask == wEventMask)
{
aEvents[i].hWnd = NULL ;
aEvents[i].nCid = 0 ;
aEvents[i].fPostFlag = FALSE ;
aEvents[i].wEventMask = 0 ;
aEvents[i].wMsg = NULL ;
aEvents[i].lpEventPtr = NULL ;
break;
}
}
// if no events in the list, kill the system timer
for (i=0; i < MAXEVENTS; i++)
if (aEvents[i].hWnd != NULL)
return ;
KillTimer( NULL, nIdTimer ) ;
FreeProcInstance( lpTimerProc ) ;
lpTimerProc = NULL ;
nIdTimer = 0 ;
return ;
} /* end of KillEvent() */
/************************************************************************
* BOOL ClearEvent( HWND hWnd, int nCid, WORD wEventMask )
*
* Description:
* Clears the post flag for the given event.
*
* Comments:
* 5/ 8/91 baw Wrote it.
*
************************************************************************/
BOOL ClearEvent( HWND hWnd, int nCid, WORD wEventMask )
{
int i ;
for (i = 0; i < MAXEVENTS; i++)
{
if (aEvents[i].hWnd == hWnd &&
aEvents[i].nCid == nCid &&
aEvents[i].wEventMask == wEventMask)
{
aEvents[i].fPostFlag = FALSE ;
return ( TRUE ) ;
}
}
return ( FALSE ) ;
} /* end of ClearEvent() */
/************************************************************************
* End of File: comevent.c
************************************************************************/